import { ref } from 'vue';
import { UUID } from '@/util/rnd.js';

// --- pointerdown ---
export const isSelfTrigger = R.converge(R.equals, [R.prop('target'), R.prop('currentTarget')])
// export const isSelfTrigger = event => event.target == event.currentTarget;
export const globalBasedOn = R.curry((o, p) => o.toLocal(p));
export const calcPointerDownOffsetOn = R.curry( (currentTarget, global) => ({ x: global.x - currentTarget.x, y: global.y - currentTarget.y }) );
export const calcPosBasedOn = R.curry( (offset, global) => ({ x: global.x - offset.x, y: global.y - offset.y }) );

// --- function ---
export const DirSign = R.prop(R.__, { prev: -1, next: 1 });
export const SideProp = R.prop(R.__, { x: 'width', y: 'height' });
export const assignId = o => (o.id = UUID(), o);

// --- data ---
export const reasonList = ref(['漏标', '错标', '多标']);
export const CommentOwn = () => ({
  rejectReason: reasonList.value[0],
  remark: '',
});

/** 设置选项 */
export const AppOpts = () => ({
  /** 选择标签前排序 */
  autoLabelSort: false,

  /** 十字参考线 */
  crosshair: {
    visible: true,
  },

  /** 标注后选中 */
  selectNewly: true,

  /** 醒目块 */
  eyeCatcher: {
    alpha: .5,
  },

  ctrlPoint: {
    /** 控制点半径 */
    r: 4,
  },
});
